<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>5.佳丽列表</title>
    <script src="./vue.global.js"></script>
</head>
<body>
<div id="vueApp">

</div>
<script type="application/javascript">
    const app = Vue.createApp({
        data() {
            return {
                inputValue: '',
                list: ['大脚', '刘英', '晓红']
            }
        },
        methods : {
            handleAddItem() {
                this.list.push(this.inputValue);
                this.inputValue = '';
            }
        },
        template: `
          <div>
          <my-title />
          <input v-model="inputValue" />
          <button v-on:click="handleAddItem">增加佳丽</button>
          <ul>
            <my-jl
                v-for="(item,index) of list"
                v-bind:item="item"
                v-bind:index="index"
            />
          </ul>
          </div>
        `
    });
    app.component('my-title', {
        template:'<h1 style="text-align: center">象牙山洗脚城</h1>'});
    app.component('my-jl', {
        props: ['item', 'index'],
        template: `<li>[{{index+1}}]-{{item}}</li>`
    });
    app.mount("#vueApp");
</script>
</body>
</html>